public class Solution {
    //如果mn>nm说明m>n
    public static boolean compare(int m, int n){
        String m1 = String.valueOf(m);
        String n1 = String.valueOf(n);
        String s1 = m1+n1;
        String s2 = n1+m1;
        if(s1.compareTo(s2)>=0){
            return true;
        }else{
            return false;
        }
    }
    public static void exchange(int i,int j, int[] numbers){
        int temp = numbers[i];
        numbers[i] = numbers[j];
        numbers[j] = temp;
    }
    public static  int partition(int[] numbers, int start, int end){

        int base = start;
        start = start+1;
        while(start<=end){
            while(start<=end && compare(numbers[base],numbers[start])){
                start++;
            }
            while(start<=end && compare(numbers[end],numbers[base])){
                end--;
            }
            if(start<end)
                exchange(start,end,numbers);
        }
        exchange(base,start-1,numbers);
        return start-1;
    }
    public static void quickSort(int[] numbers,int start, int end){
        if(start>=end)
            return;
        int mid = partition(numbers,start,end);
        quickSort(numbers,start,mid-1);
        quickSort(numbers,mid+1,end);
    }
    public static String PrintMinNumber(int [] numbers) {
        quickSort(numbers,0,numbers.length-1);
        String result="";
        for(int i=0; i<numbers.length; i++){
            result += String.valueOf(numbers[i]);
        }
        return result;
    }
    public static void main(String args[]){
        int k=2;
        int[] numbers={3,32,321};
        String b = PrintMinNumber(numbers);
        System.out.println(b);
    }

}

